package com.EAIPClub.ResourcesInfoManager.controller;

import com.EAIPClub.ResourcesInfoManager.service.ResourcesInfoManagerBaseInfoService;
import com.api.POJO.ResourcesInfoManager.ResourcesInfoManagerBaseInfo;
import com.api.POJO.ResourcesInfoManager.ResourcesInfoManagerReturnMsg;
import com.api.POJO.ResourcesInfoManager.ResourcesInfoManagerUserFileInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @Description :
 * @Author :
 * @Date : 2021/11/2
 */
@RestController
@RequestMapping("/res/fileinfo")
@Api
public class ResourcesInfoManagerBaseInfoController {

    private ResourcesInfoManagerBaseInfoService service;
    @Autowired
    public void setService(ResourcesInfoManagerBaseInfoService service) {
        this.service = service;
    }

    @PostMapping("/add")
    @ApiOperation(value = "新增静态资源基本信息",produces = "application/json")
    ResourcesInfoManagerReturnMsg addNewBaseInfo(@RequestBody ResourcesInfoManagerBaseInfo baseInfo){
        return service.addNewBaseInfo(baseInfo);
    }
    @GetMapping("/get/id/{id}")
    @ApiOperation(value = "通过id得到静态资源信息",produces = "application/json")
    ResourcesInfoManagerReturnMsg getBaseInfoById(@PathVariable Integer id){
        return service.getBaseInfoById(id);
    }
    @GetMapping("/get/uid/{uid}")
    @ApiOperation(value = "通过uid得到静态资源信息",produces = "application/json")
    ResourcesInfoManagerReturnMsg getBaseInfoByUid(@PathVariable String uid){
        return service.getBaseInfoByUid(uid);
    }
    @GetMapping("/get/filename/{filename}")
    @ApiOperation(value = "通过文件名得到静态资源信息",produces = "application/json")
    ResourcesInfoManagerReturnMsg getBaseInfoByFileName(@PathVariable String filename){
        return service.getBaseInfoByFileName(filename);
    }
    @GetMapping("/get/filesize/{filesize}")
    @ApiOperation(value = "通过文件大小得到静态资源信息",produces = "application/json")
    ResourcesInfoManagerReturnMsg getBaseInfoByFileSize(@PathVariable String filesize){
        return service.getBaseInfoByFileSize(filesize);
    }
    @GetMapping("/get/date/{date}")
    @ApiOperation(value = "通过日期得到静态资源信息",produces = "application/json")
    ResourcesInfoManagerReturnMsg getBaseInfoByDate(@PathVariable String date){
        return service.getBaseInfoByDate(date);
    }
    @GetMapping("/get/md5/{md5}")
    @ApiOperation(value = "通过MD5得到静态资源信息",produces = "application/json")
    ResourcesInfoManagerReturnMsg getBaseInfoByMD5(@PathVariable String md5){
        return service.getBaseInfoByMD5(md5);
    }
    @GetMapping("/get/hdfs/{hdfs}")
    @ApiOperation(value = "通过是否存储到hdfs得到静态资源信息",produces = "application/json")
    ResourcesInfoManagerReturnMsg getBaseInfoByHdfs(@PathVariable Character hdfs){
        return service.getBaseInfoByHdfs(hdfs);
    }
    @GetMapping("/get/location/{location}")
    @ApiOperation(value = "通过存储位置得到静态资源信息",produces = "application/json")
    ResourcesInfoManagerReturnMsg getBaseInfoByLocation(@PathVariable String location){
        return service.getBaseInfoByLocation(location);
    }
    @PutMapping("/update/id/{id}")
    @ApiOperation(value = "通过id更新静态资源信息",produces = "application/json")
    ResourcesInfoManagerReturnMsg updateBaseInfoById(@PathVariable Integer id,@RequestBody ResourcesInfoManagerBaseInfo baseInfo){
        return service.updateBaseInfoById(id,baseInfo);
    }
    @PutMapping("/update/uid/{uid}")
    @ApiOperation(value = "通过uid更新静态资源信息",produces = "application/json")
    ResourcesInfoManagerReturnMsg updateBaseInfoByUid(@PathVariable String uid ,@RequestBody ResourcesInfoManagerUserFileInfo fileInfo){
        return service.updateBaseInfoByUid(uid,fileInfo);
    }
    @DeleteMapping("/delete/id/{id}")
    @ApiOperation(value = "通过id删除静态资源信息",produces = "application/json")
    ResourcesInfoManagerReturnMsg deleteBaseInfoById(@PathVariable Integer id){
        return service.deleteBaseInfoById(id);
    }
    @DeleteMapping("/delete/uid/{uid}")
    @ApiOperation(value = "通过uid删除静态资源信息",produces = "application/json")
    ResourcesInfoManagerReturnMsg deleteBaseInfoByUid(@PathVariable String uid){
        return service.deleteBaseInfoByUid(uid);
    }
}
